package com.itheima;

import java.util.*;
import java.util.function.Consumer;

/**
 * @auther Macrydy
 * @date 2020/7/1 15:06
 */
public class StreamDemo {
    public static void main(String[] args) {
        //数组
//        method1();

        //单列集合
//        method2();

        //双列集合
        method3();
    }

    private static void method3() {
        Map<Integer, String> map = new HashMap<>();
        map.put(1, "zhangsan");
        map.put(2, "lisi");
        map.put(3, "wangwu");

        Set<Integer> keySet = map.keySet();
        keySet.stream().forEach((i) -> System.out.println(i));

        Set<Map.Entry<Integer, String>> entries = map.entrySet();
        entries.stream().forEach(new Consumer<Map.Entry<Integer, String>>() {
            @Override
            public void accept(Map.Entry<Integer, String> integerStringEntry) {
                System.out.println(integerStringEntry.getKey());
            }
        });
    }

    private static void method2() {
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);

        list.stream().forEach(i -> System.out.println(i));
    }

    private static void method1() {
        Integer[] arr = {1, 2, 3};
        Arrays.stream(arr).forEach(integer -> System.out.println(integer));
    }
}
